#include "lolevel.h"
#include "platform.h"
#include "core.h"

static long *nrflag = (long*)0x6688;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FF97DD78_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4-R6,LR}\n"
                "LDR     R3, =0x6193C\n"
                "LDR     R5, =0x6684\n"
                "SUB     SP, SP, #4\n"
                "LDR     R1, =0xFFFFFFFF\n"
                "STR     R0, [R5]\n"
                "LDR     R0, [R3]\n"
                "BL      sub_FF81FF40\n"
                "LDR     R3, =0x92DE0\n"
                "LDR     R0, [R3,#0x74]\n"
                //"BL      nullsub_31\n"
                "BL      sub_FF97DCCC\n"
         //   "BL      wait_until_remote_button_is_released\n"
	    	"BL      capt_seq_hook_set_nr\n"
                "LDR     R3, =0x668C\n"
                "LDR     R0, [R3]\n"

		"B       sub_FF97DDB0\n"
    );
}

void __attribute__((naked,noinline)) sub_FF97A124_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4-R7,LR}\n"
                "LDR     R4, [R0,#0xC]\n"
                "BL      sub_FF983D84\n"
                "CMP     R0, #0\n"
                "BNE     loc_FF97A13C\n"
                "BL      sub_FF983D90\n"
"loc_FF97A13C:\n"
                "LDR     R1, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R1]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "BNE     loc_FF97A198\n"
                "LDRH    R3, [R1,#0x80]\n"
                "CMP     R3, #3\n"
                "BEQ     loc_FF97A198\n"
                "LDRH    R3, [R1,#0x7E]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A198\n"
                "LDRH    R3, [R1,#0x7A]\n"
                "CMP     R3, #1\n"
                "BNE     loc_FF97A198\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A198\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A198\n"
                "BL      sub_FF97D9C4\n"
"loc_FF97A198:\n"
                "MOV     R0, #0xC\n"
                "BL      sub_FF983DA4\n"
                "TST     R0, #1\n"
                "BEQ     loc_FF97A1BC\n"
                "MOV     R0, #1\n"
"loc_FF97A1AC:\n"
                "MOV     R2, R4\n"
                "MOV     R1, #1\n"
                "LDMFD   SP!, {R4-R7,LR}\n"
                "B       sub_FF9783E4\n"
"loc_FF97A1BC:\n"
                "MOV     R0, #2\n"
                "LDR     R6, =0x92D20\n"
                "BL      sub_FFB01384\n"
                "ADD     R3, R4, R4,LSL#1\n"
                "MOV     R5, R3,LSL#5\n"
                "ADD     R7, R6, #8\n"
                "LDR     R3, [R7,R5]\n"
                "CMP     R3, #0\n"
                "BEQ     loc_FF97A1E4\n"
                "BL      sub_FF962E94\n"
"loc_FF97A1E4:\n"
                "MOV     R0, R4\n"
                "BL      sub_FF97C7B8\n"
                "MOV     R0, R4\n"
                "BL      sub_FF97C7F4\n"
                "TST     R0, #1\n"
                "BNE     loc_FF97A1AC\n"
                "BL      sub_FF9C0724\n"
                "BL      sub_FF824B88\n"
                "ADD     R3, R6, #4\n"
                "STR     R0, [R3,R5]\n"
                "MOV     R0, R4\n"
                "BL      sub_FF97E4FC\n"
                "BL      sub_FF97CD9C\n"
                "BL      sub_FF97CD38\n"
                "MOV     R0, R4\n"
                "BL      sub_FF97DD78_my\n"
                "BL      capt_seq_hook_raw_here\n"
                "MOV     R1, #1\n"
                "MOV     R2, R4\n"
                "BL      sub_FF9783E4\n"
                "BL      sub_FF97DF88\n"
                "LDR     R3, [R7,R5]\n"
                "CMP     R3, #0\n"
                "BEQ     loc_FF97A244\n"
                "BL      sub_FF962EB4\n"
"loc_FF97A244:\n"
                "LDR     R1, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R1]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "LDMNEFD SP!, {R4-R7,PC}\n"
                "LDRH    R3, [R1,#0x80]\n"
                "CMP     R3, #3\n"
                "LDMEQFD SP!, {R4-R7,PC}\n"
                "LDRH    R3, [R1,#0x7E]\n"
                "CMP     R3, #0\n"
                "LDMNEFD SP!, {R4-R7,PC}\n"
                "LDRH    R3, [R1,#0x7A]\n"
                "CMP     R3, #1\n"
                "LDMNEFD SP!, {R4-R7,PC}\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "LDMNEFD SP!, {R4-R7,PC}\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "LDMNEFD SP!, {R4-R7,PC}\n"
                "MOV     R0, R4\n"
                "LDMFD   SP!, {R4-R7,LR}\n"
                "B       sub_FF97D970\n"
    );
}

void __attribute__((naked,noinline)) capt_seq_task()
{
	asm volatile (
                "STMFD   SP!, {R4,LR}\n"
                "SUB     SP, SP, #4\n"
                "MOV     R4, SP\n"
                "B       loc_FF97A8F8\n"
"loc_FF97A630:\n"
                "LDR     R1, [SP,#0xC-0xC]\n"
                "LDR     R3, [R1]\n"
                "MOV     R0, R1\n"
                "CMP     R3, #0x15\n"
                "LDRLS   PC, [PC,R3,LSL#2]\n"
                "B       loc_FF97A8D0\n"
                ".long loc_FF97A6A0\n"
                ".long loc_FF97A6AC\n"
                ".long loc_FF97A6B4\n"
                ".long loc_FF97A720\n"
                ".long loc_FF97A718\n"
                ".long loc_FF97A784\n"
                ".long loc_FF97A7E8\n"
                ".long loc_FF97A7F4\n"
                ".long loc_FF97A7FC\n"
                ".long loc_FF97A808\n"
                ".long loc_FF97A810\n"
                ".long loc_FF97A818\n"
                ".long loc_FF97A820\n"
                ".long loc_FF97A828\n"
                ".long loc_FF97A830\n"
                ".long loc_FF97A83C\n"
                ".long loc_FF97A844\n"
                ".long loc_FF97A84C\n"
                ".long loc_FF97A854\n"
                ".long loc_FF97A860\n"
                ".long loc_FF97A868\n"
                ".long loc_FF97A870\n"
"loc_FF97A6A0:\n"
                "BL      sub_FF97C09C\n"
                "BL      shooting_expo_param_override\n"  // +
                "BL      sub_FF977E9C\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A6AC:\n"
                "BL      sub_FF97A124_my\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A6B4:\n"
                "LDR     R1, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R1]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "BNE     loc_FF97A710\n"
                "LDRH    R3, [R1,#0x80]\n"
                "CMP     R3, #3\n"
                "BEQ     loc_FF97A710\n"
                "LDRH    R3, [R1,#0x7E]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A710\n"
                "LDRH    R3, [R1,#0x7A]\n"
                "CMP     R3, #1\n"
                "BNE     loc_FF97A710\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A710\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A710\n"
                "BL      sub_FF97D9C4\n"
"loc_FF97A710:\n"
                "BL      sub_FF97C7A8\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A718:\n"
                "BL      sub_FF97B384\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A720:\n"
                "LDR     R1, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R1]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "BNE     loc_FF97A77C\n"
                "LDRH    R3, [R1,#0x80]\n"
                "CMP     R3, #3\n"
                "BEQ     loc_FF97A77C\n"
                "LDRH    R3, [R1,#0x7E]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A77C\n"
                "LDRH    R3, [R1,#0x7A]\n"
                "CMP     R3, #1\n"
                "BNE     loc_FF97A77C\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A77C\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A77C\n"
                "BL      sub_FF97D9C4\n"
"loc_FF97A77C:\n"
                "BL      sub_FF97B724\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A784:\n"
                "LDR     R1, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R1]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "BNE     loc_FF97A7E0\n"
                "LDRH    R3, [R1,#0x80]\n"
                "CMP     R3, #3\n"
                "BEQ     loc_FF97A7E0\n"
                "LDRH    R3, [R1,#0x7E]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A7E0\n"
                "LDRH    R3, [R1,#0x7A]\n"
                "CMP     R3, #1\n"
                "BNE     loc_FF97A7E0\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A7E0\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A7E0\n"
                "BL      sub_FF97D9C4\n"
"loc_FF97A7E0:\n"
                "BL      sub_FF97B734\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A7E8:\n"
                "BL      sub_FF97C180\n"
                "BL      sub_FF977E9C\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A7F4:\n"
                "BL      sub_FF97A320\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A7FC:\n"
                "BL      sub_FF97C1E8\n"
                "BL      sub_FF977E9C\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A808:\n"
                "BL      sub_FF97B724\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A810:\n"
                "BL      sub_FF97CDDC\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A818:\n"
                "BL      sub_FF97D120\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A820:\n"
                "BL      sub_FF97D1A4\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A828:\n"
                "BL      sub_FF97D2A0\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A830:\n"
                "MOV     R0, #0\n"
                "BL      sub_FF97D368\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A83C:\n"
                "BL      sub_FF97D504\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A844:\n"
                "BL      sub_FF97D598\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A84C:\n"
                "BL      sub_FF97D654\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A854:\n"
                "MOV     R0, #1\n"
                "BL      sub_FF97D368\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A860:\n"
                "BL      sub_FF97D740\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A868:\n"
                "BL      sub_FF97D810\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A870:\n"
                "LDR     R0, =0x92DE0\n"
                "MOV     R3, #0x8000\n"
                "LDRH    R2, [R0]\n"
                "ADD     R3, R3, #7\n"
                "CMP     R2, R3\n"
                "BNE     loc_FF97A8E0\n"
                "LDRH    R3, [R0,#0x80]\n"
                "CMP     R3, #3\n"
                "BEQ     loc_FF97A8E0\n"
                "LDRH    R3, [R0,#0x7E]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A8E0\n"
                "LDRH    R3, [R0,#0x7A]\n"
                "CMP     R3, #1\n"
                "BNE     loc_FF97A8E0\n"
                "LDR     R2, =0x92E80\n"
                "LDR     R3, [R2,#0x1C]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A8E0\n"
                "LDR     R3, [R2,#0x18]\n"
                "CMP     R3, #0\n"
                "BNE     loc_FF97A8E0\n"
                "BL      sub_FF97D9C4\n"
                "B       loc_FF97A8DC\n"
"loc_FF97A8D0:\n"
                "MOV     R1, #0x36C\n"
                "LDR     R0, =0xFF979EB0\n"
                "BL      sub_FF813B80\n"
"loc_FF97A8DC:\n"
                "LDR     R1, [SP,#0xC-0xC]\n"
"loc_FF97A8E0:\n"
                "LDR     R3, =0x618C4\n"
                "LDR     R1, [R1,#4]\n"
                "LDR     R0, [R3]\n"
                "BL      sub_FF81FDA4\n"
                "LDR     R0, [SP,#0xC-0xC]\n"
                "BL      sub_FF979F2C\n"
"loc_FF97A8F8:\n"
                "LDR     R3, =0x618C8\n"
                "MOV     R1, R4\n"
                "LDR     R0, [R3]\n"
                "MOV     R2, #0\n"
                "BL      sub_FF8204BC\n"
                "TST     R0, #1\n"
                "BEQ     loc_FF97A630\n"
                "MOV     R1, #0x2A4\n"
                "LDR     R0, =0xFF979EB0\n"
                "ADD     R1, R1, #2\n"
                "BL      sub_FF813B80\n"
                "BL      sub_FF821A18\n"
                "ADD     SP, SP, #4\n"
                "LDMFD   SP!, {R4,PC}\n"
	);
}

/*************************************************************/
void __attribute__((naked,noinline)) exp_drv_task(){
 asm volatile(
                 "STMFD   SP!, {R4-R8,LR}\n"
                 "SUB     SP, SP, #0x14\n"
                 "MOV     R7, SP\n"
                 "B       loc_FF913654\n"
 "loc_FF913268:\n"
                 "CMP     R2, #0x1F\n"
                 "BNE     loc_FF913280\n"
                 "LDR     R0, [R12,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x4C]\n"
                 "B       loc_FF9132E0\n"
 "loc_FF913280:\n"
                 "CMP     R2, #0x1A\n"
                 "BNE     loc_FF913294\n"
                 "MOV     R0, R12\n"
                 "BL      sub_FF913188\n"
                 "B       loc_FF9132D0\n"
 "loc_FF913294:\n"
                 "CMP     R2, #0x1B\n"
                 "BNE     loc_FF9132A8\n"
                 "MOV     R0, R12\n"
                 "BL      sub_FF9131C4\n"
                 "B       loc_FF9132D0\n"
 "loc_FF9132A8:\n"
                 "SUB     R3, R2, #0x1C\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_FF9132C0\n"
                 "MOV     R0, R12\n"
                 "BL      sub_FF913200\n"
                 "B       loc_FF9132D0\n"
 "loc_FF9132C0:\n"
                 "CMP     R2, #0x1E\n"
                 "BNE     loc_FF9132EC\n"
                 "BL      sub_FF8B55C4\n"
                 "BL      sub_FF8B73B4\n"
 "loc_FF9132D0:\n"
                 "LDR     R3, [SP]\n"
                 "LDR     R0, [R3,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x4C]\n"
 "loc_FF9132E0:\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF910B94\n"
                 "B       loc_FF913654\n"
 "loc_FF9132EC:\n"
                 "CMP     R2, #0xD\n"
                 "MOV     R8, #1\n"
                 "BNE     loc_FF91335C\n"
                 "LDR     R1, [R12,#0x40]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#1\n"
                 "ADD     R6, SP, #0xC\n"
                 "SUB     R1, R1, #2\n"
                 "MOV     R2, #6\n"
                 "MOV     R0, R6\n"
                 "BL      sub_FFB4F230\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF912158\n"
                 "LDR     R3, [SP]\n"
                 "LDR     R1, [R3,#0x40]\n"
                 "LDR     R2, [R3,#0x50]\n"
                 "ADD     R0, R3, #4\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x4C]\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF9122DC\n"
                 "LDR     R3, [SP]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x40]\n"
                 "LDR     R2, [R3,#0x58]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x54]\n"
                 "B       loc_FF913604\n"
 "loc_FF91335C:\n"
                 "SUB     R3, R2, #0xE\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_FF913418\n"
                 "ADD     R6, SP, #0xC\n"
                 "ADD     R5, SP, #4\n"
                 "MOV     R0, R12\n"
                 "MOV     R1, R6\n"
                 "MOV     R2, R5\n"
                 "BL      sub_FF912358\n"
                 "MOV     R4, R0\n"
                 "CMP     R4, #5\n"
                 "CMPNE   R4, #1\n"
                 "BNE     loc_FF9133B0\n"
                 "LDR     R12, [SP]\n"
                 "MOV     R0, R5\n"
                 "LDR     R1, [R12,#0x40]\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x4C]\n"
                 "B       loc_FF9133E8\n"
 "loc_FF9133B0:\n"
                 "CMP     R4, #6\n"
                 "CMPNE   R4, #2\n"
                 "BNE     loc_FF9133F8\n"
                 "LDR     R12, [SP]\n"
                 "MOV     R0, R5\n"
                 "MOV     R1, R8\n"
                 "MOV     R2, R4\n"
                 "LDR     R3, [R12,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x4C]\n"
                 "MOV     R1, R6\n"
                 "LDR     R0, [SP]\n"
                 "MOV     R2, R5\n"
                 "BL      sub_FF912FC4\n"
 "loc_FF9133E8:\n"
                 "MOV     R1, R4\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF913168\n"
                 "B       loc_FF913604\n"
 "loc_FF9133F8:\n"
                 "LDR     R12, [SP]\n"
                 "MOV     R2, R4\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x40]\n"
                 "LDR     R3, [R12,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x4C]\n"
                 "B       loc_FF913604\n"
 "loc_FF913418:\n"
                 "SUB     R3, R2, #0x17\n"
                 "CMP     R3, #1\n"
                 "BHI     loc_FF913470\n"
                 "LDR     R1, [R12,#0x40]\n"
                 "ADD     R1, R1, R1,LSL#1\n"
                 "ADD     R1, R12, R1,LSL#1\n"
                 "ADD     R6, SP, #0xC\n"
                 "SUB     R1, R1, #2\n"
                 "MOV     R2, #6\n"
                 "MOV     R0, R6\n"
                 "BL      sub_FFB4F230\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF911BC4\n"
                 "LDR     R3, [SP]\n"
                 "ADD     R0, R3, #4\n"
                 "LDR     R1, [R3,#0x40]\n"
                 "LDR     R2, [R3,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R3,#0x4C]\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF911E5C\n"
                 "B       loc_FF913604\n"
 "loc_FF913470:\n"
                 "ADD     R6, SP, #0xC\n"
                 "ADD     R1, R12, #4\n"
                 "MOV     R2, #6\n"
                 "MOV     R0, R6\n"
                 "BL      sub_FFB4F230\n"
                 "LDR     R12, [SP]\n"
                 "LDR     R3, [R12]\n"
                 "MOV     R2, R12\n"
                 "CMP     R3, #0x19\n"
                 "LDRLS   PC, [PC,R3,LSL#2]\n"
                 "B       loc_FF9135F0\n"
                 ".long loc_FF913504\n"
                 ".long loc_FF913510\n"
                 ".long loc_FF91351C\n"
                 ".long loc_FF91351C\n"
                 ".long loc_FF913504\n"
                 ".long loc_FF913510\n"
                 ".long loc_FF91351C\n"
                 ".long loc_FF91351C\n"
                 ".long loc_FF913540\n"
                 ".long loc_FF913540\n"
                 ".long loc_FF9135C4\n"
                 ".long loc_FF9135D0\n"
                 ".long loc_FF9135E0\n"
                 ".long loc_FF9135F0\n"
                 ".long loc_FF9135F0\n"
                 ".long loc_FF9135F0\n"
                 ".long loc_FF913528\n"
                 ".long loc_FF913534\n"
                 ".long loc_FF913550\n"
                 ".long loc_FF91355C\n"
                 ".long loc_FF913584\n"
                 ".long loc_FF9135AC\n"
                 ".long loc_FF9135AC\n"
                 ".long loc_FF9135F0\n"
                 ".long loc_FF9135F0\n"
                 ".long loc_FF9135B8\n"
 "loc_FF913504:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911140\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913510:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF91127C\n"
                 "B       loc_FF9135EC\n"
 "loc_FF91351C:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF9113AC\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913528:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911580\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913534:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911688\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913540:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF91174C_my\n"  //--------->
                 "MOV     R8, #0\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913550:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF91180C\n"
                 "B       loc_FF9135EC\n"
 "loc_FF91355C:\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#4]\n"
                 "LDR     R3, =0x3C7DC\n"
                 "STRH    R2, [SP,#0xC]\n"
                 "LDRH    R1, [R3,#4]\n"
                 "STRH    R1, [SP,#0x10]\n"
                 "LDRH    R3, [R3,#2]\n"
                 "STRH    R3, [SP,#0xE]\n"
                 "BL      sub_FF911994\n"
                 "B       loc_FF9135EC\n"
 "loc_FF913584:\n"
                 "LDR     R3, =0x3C7DC\n"
                 "LDRH    R1, [R3]\n"
                 "STRH    R1, [SP,#0xC]\n"
                 "MOV     R0, R2\n"
                 "LDRH    R2, [R2,#6]\n"
                 "STRH    R2, [SP,#0xE]\n"
                 "LDRH    R3, [R3,#4]\n"
                 "STRH    R3, [SP,#0x10]\n"
                 "BL      sub_FF911A28\n"
                 "B       loc_FF9135EC\n"
 "loc_FF9135AC:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911AA8\n"
                 "B       loc_FF9135EC\n"
 "loc_FF9135B8:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911EEC\n"
                 "B       loc_FF9135EC\n"
 "loc_FF9135C4:\n"
                 "MOV     R0, R2\n"
                 "BL      sub_FF911FC0\n"
                 "B       loc_FF9135EC\n"
 "loc_FF9135D0:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #0\n"
                 "BL      sub_FF9120AC\n"
                 "B       loc_FF9135EC\n"
 "loc_FF9135E0:\n"
                 "MOV     R0, R2\n"
                 "MOV     R1, #1\n"
                 "BL      sub_FF9120AC\n"
 "loc_FF9135EC:\n"
                 "LDR     R12, [SP]\n"
 "loc_FF9135F0:\n"
                 "ADD     R0, R12, #4\n"
                 "LDR     R1, [R12,#0x40]\n"
                 "LDR     R2, [R12,#0x50]\n"
                 "MOV     LR, PC\n"
                 "LDR     PC, [R12,#0x4C]\n"
 "loc_FF913604:\n"
                 "CMP     R8, #1\n"
                 "BNE     loc_FF91362C\n"
                 "LDR     R1, [SP]\n"
                 "LDR     R3, [R1,#0x40]\n"
                 "ADD     R3, R3, R3,LSL#1\n"
                 "ADD     R1, R1, R3,LSL#1\n"
                 "MOV     R0, R6\n"
                 "SUB     R1, R1, #2\n"
                 "BL      sub_FF910FA8\n"
                 "B       loc_FF91364C\n"
 "loc_FF91362C:\n"
                 "MOV     R0, #1\n"
                 "MOV     R1, R0\n"
                 "MOV     R2, R0\n"
                 "BL      sub_FF910F4C\n"
                 "MOV     R0, #1\n"
                 "MOV     R1, R0\n"
                 "MOV     R2, R0\n"
                 "BL      sub_FF911068\n"
 "loc_FF91364C:\n"
                 "LDR     R0, [SP]\n"
                 "BL      sub_FF910B94\n"
 "loc_FF913654:\n"
                 "LDR     R3, =0x3C7D4\n"
                 "MOV     R2, #0\n"
                 "LDR     R0, [R3]\n"
                 "MOV     R1, R7\n"
                 "BL      sub_FF8204BC\n"
                 "LDR     R12, [SP]\n"
                 "LDR     R2, [R12]\n"
                 "CMP     R2, #0x20\n"
                 "BNE     loc_FF913268\n"
                 "MOV     R0, R12\n"
                 "BL      sub_FF910B94\n"
                 "LDR     R3, =0x3C7D0\n"
                 "MOV     R1, #1\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_FF81FDA4\n"
                 "BL      sub_FF821A18\n"
                 "ADD     SP, SP, #0x14\n"
                 "LDMFD   SP!, {R4-R8,PC}\n"
 );
}

void __attribute__((naked,noinline)) sub_FF91174C_my(){
 asm volatile(
                 "STMFD   SP!, {R4,R5,LR}\n"
                 "LDR     R3, =0x3C7D0\n"
                 "MOV     R4, R0\n"
                 "MOV     R1, #0xE\n"
                 "LDR     R0, [R3]\n"
                 "BL      sub_FF81FF40\n"
                 "MOV     R1, #0\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "BL      sub_FF910C70\n"
                 "MOV     R5, R0\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_FF910DE4\n"
                 "LDRSH   R0, [R4,#8]\n"
                 "BL      sub_FF910E80\n"
                 "LDR     R3, [R4]\n"
                 "CMP     R3, #9\n"
                 "MOVEQ   R5, #0\n"
                 "CMP     R5, #1\n"
                 "LDR     R1, =0xFF910BC8\n"
                 "MOV     R2, #2\n"
                 "BNE     loc_FF9117B8\n"
                 "LDRSH   R0, [R4,#4]\n"
                 "BL      sub_FFAF63DC\n"
                 "LDR     R2, =0x3C7FC\n"
                 "MOV     R3, #0\n"
                 "STR     R3, [R2]\n"
                 "B       loc_FF9117BC\n"
 "loc_FF9117B8:\n"
                 "BL      sub_FF910F1C\n"
 "loc_FF9117BC:\n"
                 "STRH    R0, [R4,#4]\n"
                 "LDRSH   R0, [R4,#6]\n"
                 "BL      sub_FF8B524C_my\n"  //----------->
                 "LDRSH   R0, [R4,#8]\n"
                 "MOV     R1, #1\n"
                 "BL      sub_FF8B6F74\n"
                 "MOV     R1, #0\n"
                 "ADD     R0, R4, #8\n"
                 "BL      sub_FF8B7034\n"
                 "CMP     R5, #1\n"
                 "MOV     R1, #2\n"
                 "MOV     R2, #0\n"
                 "LDMNEFD SP!, {R4,R5,PC}\n"
                 "LDR     R3, =0x3C7D0\n"
                 "LDR     R0, [R3]\n"
                 "LDMFD   SP!, {R4,R5,LR}\n"
                 "B       sub_FF81FD94\n"
 );
}

void __attribute__((naked,noinline)) sub_FF8B524C_my(){
 asm volatile(
                 "STMFD   SP!, {R4,LR}\n"
                 "LDR     R3, =0x55A8\n"
                 "LDR     R2, [R3]\n"
                 "MOV     R1, #0x114\n"
                 "MOV     R3, R0,LSL#16\n"
                 "CMP     R2, #1\n"
                 "ADD     R1, R1, #1\n"
                 "LDR     R0, =0xFF8B4CC8\n"
                 "MOV     R4, R3,ASR#16\n"
                 "BEQ     loc_FF8B5278\n"
                 "BL      sub_FF813B80\n"
 "loc_FF8B5278:\n"
                 "MOV     R1, #0x118\n"
                 "CMN     R4, #0xC00\n"
                 "LDR     R3, =0x33E56\n"
                 "LDR     R0, =0xFF8B4CC8\n"
                 "ADD     R1, R1, #3\n"
                 "LDREQSH R4, [R3]\n"
                 "LDRNE   R3, =0x33E56\n"
                 "CMN     R4, #0xC00\n"
                 "STRH    R4, [R3]\n"
                 "BNE     loc_FF8B52A4\n"
                 "BL      sub_FF813B80\n"
 "loc_FF8B52A4:\n"
                 "MOV     R0, R4\n"
            //   "BL      sub_FF8B6348\n"  // -
                 "BL      apex2us\n"  // +
                 "MOV     R4, R0\n"
                 "BL      sub_FF8DD89C\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FF8B4880\n"
                 "TST     R0, #1\n"
                 "MOV     R1, #0x120\n"
                 "LDR     R0, =0xFF8B4CC8\n"
                 "LDMEQFD SP!, {R4,PC}\n"
                 "LDMFD   SP!, {R4,LR}\n"
                 "B       sub_FF813B80\n"
 );
}
